package Demo;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.*;

public class MouseMove extends JFrame{
	int a,b,x,y;
	Boolean flag=true;

	public MouseMove()
	{
		setSize(500,500);

		this.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e){
				System.out.println("\n" + e.getX()+"/"+e.getY());
				if(flag) {
					a = e.getX();
					b = e.getY();
					flag = !flag;
				}
				else {
					x = e.getX();
					y = e.getY();
					flag = !flag;
					Ve();
				}
			}
		});
	}
	public void Ve()
	{
		System.out.printf("ve diem tu (%d,%d) den (%d,%d)",a,b,x,y);
	}
	public static void main(String args[])
	{
		new MouseMove().setVisible(true);
	}
}
